package com.sunrate.investingquote.service.router.match;

import com.sunrate.investingquote.bean.router.ChannelRouter;
import com.sunrate.investingquote.dto.router.RouterMatchParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author yyh
 * @description:
 * @date 2023/06/29/ 14:03
 */
@Component
public class RouterMatchContext {
    @Autowired
    private List<RouterMatch> routerMatchList;

    public boolean match(RouterMatchParam order, ChannelRouter router) {
        if (CollectionUtils.isEmpty(routerMatchList)) {
            return false;
        }
        return routerMatchList.stream().allMatch(matcher -> matcher.match(order, router));
    }
}
